import InteractiveBase from "../../../LevelCommon/InteractiveBase";
import HourPoint from "./HourPoint";
import LevelBaseControl from "../../../LevelCommon/LevelBaseControl";
import DialogDataConst from "../../../../constant/DialogDataConst";

export default class Clock extends InteractiveBase{
     /** 是否已经对了*/
     private isFinish :boolean= false;
     /** 时针*/
     private hourPoint:HourPoint;
     /** 需要的道具id*/
     public  needPropId:number;
     private levelControl:LevelBaseControl;

     private mowner :Laya.Sprite3D;
     onStart()
     {
         this.mowner = this.owner as Laya.Sprite3D;
        this.hourPoint = this.mowner.getChildByName("hourPoint").getComponent(HourPoint);  
        this.levelControl =window.gameFacade.LevelMng.GetCurLevelControl();
     }
     protected  InteractiveLogic():boolean
     {
         if (!this.hourPoint.owner.activeInHierarchy)
         {
             /** 如果选择了需要的道具 就使用*/
             if(this.levelControl.IsSelectProp(this.needPropId))
             {
                 this.levelControl.UseCurProp();
                 this.hourPoint.owner.active = true
                 return true;
             }
         }
         return false;
     }
     /** 点击按钮 确定*/
     public  OnClickClockBtn():void
     {
         if (!this.isFinish)
         {
             this.isFinish = this.hourPoint.CheckIsTrue();
             if (!this.isFinish)
             {
                this.levelControl.ShowDialog(DialogDataConst.nothing_happened);
             }
         }
     }
}